interface MyArray<T> {
  [n: number]: T;
}

let arr: MyArray<number> = [1, 2, 3, 4];
console.log(arr);

let arr2: Array<number> = [1, 2, 3, 4];

type PropsKey = "x" | "y" | "z";
type Type1 = { x: number; y: number; z: number };

type Type2 = { [K in PropsKey]: number };

type Type3 = { x: number; y: string; z: boolean };
type Type4 = { [K in keyof Type3]: number };

let x1: Type1 = {
  x: 1,
  y: 1,
  z: 1,
};
let x2: Type2 = {
  x: 1,
  y: 1,
  z: 1,
};
let x3: Type3 = {
  x: 1,
  y: "1",
  z: true,
};
let x4: Type4 = {
  x: 1,
  y: 1,
  z: 1,
};

console.log(x1);
console.log(x2);
console.log(x3);
console.log(x4);

// 有定义的属性和类型,   查询所有属性的类型
type Props = { x: string; y: number; z: boolean };
type Type5 = Props["x" | "y" | "z"];
let x: Type5 = true;
